# -*- mode: snippet -*-
# name: ggplot geom_violin template
# key: ggplot2.geom_violin.template
# key: geom_violin.template@ggplot2
# contributor: Shuguang Sun
# --
# library(hrbrthemes)
# library(viridis)
ggplot(${1:dt}, aes(x = ${2:as.factor(${3:x})}, y = ${4:y})) + # define x and y axis variables
  geom_violin(
  # position = position_dodge(1), # for grouped violin
  ) +
  stat_summary(
  fun = mean,
  geom = "point",
  shape = 23,
  size = 4
  ) +
  stat_summary(
  fun.data = "mean_sdl", # require(Hmisc), median_hilow, etc.
  fun.args = list(mult = 1)
  ) +
  # scale_fill_viridis(discrete = TRUE, alpha=0.6) +
  # geom_dotplot(binaxis='y', stackdir='center', dotsize=0.3) + # Box plot with dot plot
  # Box plot with jittered points
  geom_jitter(color = "black", size = 1, alpha = 0.9, shape = 16, position=position_jitter(0.2)) +
  # coord_flip() + # Rotate the box plot
  scale_x_discrete(limits=c("20", "40")) + # Choose which factors to display
  labs(x = "", y = "")
